//
// Created by ZLY on 2025/3/29.
//

#ifndef VIDEOOUTPUT_H
#define VIDEOOUTPUT_H
#include "AVFrameQueue.h"
#include <thread>
#include <SDL3/SDL.h>
#include <memory>
class VideoOutput {
public:
    VideoOutput(AVFrameQueue *frame_queue, int video_width, int video_height);

    int Init();

    int MainLoop();

    void VideoRefresh(double * remaining_time);

    void RefreshLoopWaitEvent(SDL_Event *event);

    ~VideoOutput();

private:
    AVFrameQueue *frame_queue_ = nullptr;
    int video_width_ = 450;
    int video_height_ = 300;
    SDL_Event event_;
    SDL_Rect rect_;
    SDL_Window *window_ = nullptr;
    SDL_Renderer *renderer_ = nullptr;
    SDL_Texture *texture_ = nullptr;
    uint8_t *yuv_buffer_ = nullptr;
    SDL_Mutex *mutex_ = nullptr;
    int yuv_buffer_size_ = 0;
};


#endif //VIDEOOUTPUT_H
